package aar.test.tessocr;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import aar.test.tessocr.baseApplication.BaseApplication;
import aar.test.tessocr.utils.PrefUtils;
import clx.tessocr.ocreng.R;
import lib_zxing.activity.CaptureActivity;
import lib_zxing.activity.CodeUtils;
import okgo.OkGo;

public class LogInfoActivity extends AppCompatActivity {

    private LinearLayout appointment_order,site_dispatch,list_of_cabinet,pie_list,capital_details,open_cab;

    private TextView user_name;
    private TextView login_cab;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_long_info);
        initView();
    }

    private void initView(){

        login_cab=findViewById(R.id.login_cab);

        login_cab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivityForResult(new Intent(LogInfoActivity.this, ScanLoginCabActivity.class),100);

            }
        });


        user_name=findViewById(R.id.user_name);

        user_name.setText(PrefUtils.getString(this, "userName", ""));



        appointment_order=findViewById(R.id.appointment_order);

        appointment_order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, AppointmentOrderActivity.class));



            }
        });

        site_dispatch=findViewById(R.id.site_dispatch);

        site_dispatch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, SiteDispatchActivity.class));

            }
        });

        list_of_cabinet=findViewById(R.id.list_of_cabinet);

        list_of_cabinet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, ListofCabinetActivity.class));

            }
        });
        pie_list=findViewById(R.id.pie_list);

        pie_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, PieListActivity.class));

            }
        });



        capital_details=findViewById(R.id.capital_details);

        capital_details.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, CapitalDetailsActivity.class));

            }
        });



        open_cab=findViewById(R.id.open_cab);

        open_cab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(LogInfoActivity.this, OpenCabActivity.class));

            }
        });
    }




    @Override
    protected void onDestroy() {
        super.onDestroy();
        //Activity销毁时，取消网络请求
        OkGo.getInstance().cancelTag(this);




    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);



        if(resultCode==RESULT_OK){

            if(null!=data){

                int mm=data.getIntExtra(CodeUtils.RESULT_TYPE,CodeUtils.RESULT_FAILED);

                if(mm==CodeUtils.RESULT_SUCCESS){

                    login_cab.setText("登陆成功");

//                    Toast.makeText(LogInfoActivity.this, "扫描成功---"+res, Toast.LENGTH_LONG).show();

                }else  if(mm==CodeUtils.RESULT_FAILED){

//                    Toast.makeText(LogInfoActivity.this, "扫描失败", Toast.LENGTH_LONG).show();
                    login_cab.setText("登陆柜子");

                }
            }


        }




    }
}
